a,b=10,3

print("整型基本运算\n")
print(f"{a}+{b}={a+b}")
print(f"{a}-{b}={a-b}")
print(f"{a}*{b}={a*b}")
print(f"{a}/{b}={a/b}")  # 除法: 3.333... (返回浮点数)

print(f"{a}//{b}={a//b}")  # 整除: 3
print(f"{a}%{b}={a%b}")
print(f"{a}**{b}={a**b}") # 幂运算 类似Math.pow(a,b)
print(f"-{a}={-a}")
print(f"+{a}={+a}")


#位运算
x, y = 5, 3
# 5 = 0b101
# 3 = 0b011

print("位运算:")
print(f"{x} & {y} = {x & y}")      # 按位与: 0b101 & 0b011 = 0b001 = 1
print(f"{x} | {y} = {x | y}")      # 按位或: 0b101 | 0b011 = 0b111 = 7
print(f"{x} ^ {y} = {x ^ y}")      # 按位异或: 0b101 ^ 0b011 = 0b110 = 6 异或是指两个位不同则返回1，相同则返回0
print(f"~{x} = {~x}")              # 按位取反: ~0b101 = -6 (补码表示)  −x−1 00000101→11111010-1→11111001→ 00000110
print(f"{x} << 1 = {x << 1}")      # 左移: 0b101 << 1 = 0b1010 = 10 左移是乘以2
print(f"{x} << 1 = {x << 2}")      # 左移: 0b101 << 1 = 0b1010 = 10 左移是乘以2
print(f"{x} >> 1 = {x >> 1}")      # 右移: 0b101 >> 2 = 0b10 = 20 右移是除以2
print(f"{x} >> 1 = {x >> 2}")      # 右移: 0b101 >> 2 = 0b10 = 1 右移是除以2


#
a, b ,c = 10, 5, 7
# 链式比较
print(f"\n链式比较:")
print(f"{b} < {c} < {a}: {b < c < a}")  # True
print(f"{a} > {c} > {b}: {a > c > b}")  # True
print(f"{b}<{a}<{c}，{b<a<c}")

